<?php

function helpers() {
	$helpers = func_get_args();
	foreach($helpers as $helper) include_once(ENGINE.'helpers'.DS.$helper.'_helper.php');
}

function my_helpers() {
	$helpers = func_get_args();
	foreach($helpers as $helper) include_once(HELPERS.$helper.'_helper.php');
}

function cut_str($str,$num=40) { 
  	$str = substr($str, 0, $num); 
  	$str = substr($str, 0, $num-strlen(strrchr($str, ' '))); 
  	return $str;
}

function sanitize($text='') {
	$text = strtolower($text);
	$textdecode = utf8_decode($text);
	if(utf8_encode($textdecode) == $text) $text = $textdecode;
	$text = htmlentities($text);
	$text = preg_replace('!&(.{1})(tilde|acute);!', '\\1', $text);
	$text = preg_replace('!&.+;!', '', $text);
	$text = trim(preg_replace('![^[:alnum:]]!', ' ', $text));						
	$text = preg_replace('!\s+!', '-' , $text);		
	return $text;
}

function is_utf8($string) {
   	$string_utf8 = utf8_encode($string);
   	if(strpos($string_utf8,"�",0) !== false) return true;
	return false;
}

function tag($tag, $value='', $atts=array(), $force=false) {
	if(!$value && !$force) return '<'.$tag.atts($atts).' />';
	return '<'.$tag.atts($atts).'>'.$value.'</'.$tag.'>';
}

function atts($atts_values=array()) {
	$atts = array();
	foreach($atts_values as $key => $value)
		$atts[] = $key.'="'.$value.'"';
	return (count($atts)) ? chr(32).join(chr(32),$atts) : '';
}

?>